@echo off
REM ========================================
REM 使用溢出检测工具启动若依项目示例
REM ========================================

echo.
echo ========================================
echo   带溢出检测的若依项目启动脚本
echo ========================================
echo.

REM 设置Agent路径
set DETECTOR_JAR=%~dp0..\target\overflow-detector-1.0.0.jar

REM 检查Agent是否存在
if not exist "%DETECTOR_JAR%" (
    echo [错误] 检测工具未构建，请先执行:
    echo        cd overflow-detector-tool
    echo        mvn clean package
    pause
    exit /b 1
)

REM 设置若依项目路径
set RUOYI_JAR=%~dp0..\..\ruoyi-admin\target\ruoyi-admin.jar

REM 检查若依项目是否存在
if not exist "%RUOYI_JAR%" (
    echo [错误] 若依项目未构建，请先执行:
    echo        mvn clean package
    pause
    exit /b 1
)

echo [信息] Agent路径: %DETECTOR_JAR%
echo [信息] 项目路径: %RUOYI_JAR%
echo.

REM 配置检测参数
set JAVA_OPTS=-javaagent:%DETECTOR_JAR%
set JAVA_OPTS=%JAVA_OPTS% -Doverflow.packages=com.ruoyi
set JAVA_OPTS=%JAVA_OPTS% -Doverflow.threshold=0.7
set JAVA_OPTS=%JAVA_OPTS% -Doverflow.logfile=overflow-monitor.log
set JAVA_OPTS=%JAVA_OPTS% -Doverflow.maxWarnings=5

echo [信息] 启动参数: %JAVA_OPTS%
echo.
echo [提示] 日志将保存到: overflow-monitor.log
echo [提示] 按 Ctrl+C 停止服务
echo.

REM 启动项目
java %JAVA_OPTS% -jar "%RUOYI_JAR%"

pause
